package com.weixing.mall.provider.controller.front;

import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.annotation.NoNeedAccess;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.model.enums.cms.NewsTypeEnum;
import com.weixing.mall.provider.service.INewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName NewsController
 * @Description TODO <br/>
 * @Author gjq
 * @Modified By:
 * @Date 2019/9/18
 * @Version 1.0
 **/
@RestController
@RequestMapping("front/news")
@Api(value = "前端新闻api",tags = "前端:新闻")
public class FrontNewsController extends BaseController {


    @Autowired
    private INewsService newsService;

    @ApiOperation(value = "按类型加载新闻列表")
    @PostMapping("{type}")
    @NoNeedAccess
    public Result list(@PathVariable  NewsTypeEnum type){
        return ResultUtil.success(newsService.selectNewsFrontVoList(initMpPage(),type));
    }

    @ApiOperation(value = "按照ID来查询新闻和公告")
    @GetMapping("getById/{id}")
    @NoNeedAccess
    public Result list(@PathVariable  Long id){
        return ResultUtil.success(newsService.getById(id));
    }
}
